package com.cn.wanxi.util.utils;

import com.cn.wanxi.util.model.NewsModel;

import java.util.ArrayList;
import java.util.List;

public class NewsUtile {
    FileUtile fileUtile =new FileUtile();
    public List<NewsModel> readNews(){
        List<NewsModel> newsModels = new ArrayList<>();
        String newtext = fileUtile.readFileToString("NewsFile.txt");
        String[] news = newtext.split(";");
        for (int i=0;i<news.length;i++){
            String item = news[i];
            String[] info = item.split(",");
            NewsModel newsModel =new NewsModel(info[0].trim(),info[1].trim(),info[2].trim(),info[3].trim(),info[4].trim());
            newsModels.add(newsModel);
        }
        return newsModels;
    }
}
